/*
 * Copyright (c) 2011 Obix Labs Limited
 * Redistribution and use in source and binary forms, 
 * with or without modification, are permitted provided 
 * that the following conditions are met:
 * 
 * 		Redistribution of source code must retain the above 
 * 		copyright notice, this list of conditions and the 
 * 		following disclaimer.
 *
 * 		Redistribution in binary form must reproduce the 
 * 		above copyright notice, this list of conditions 
 * 		and the following disclaimer in the documentation 
 * 		and/or other materials provided with the distribution.
 * 
 * 	THIS SOFTWARE IS PROVIDED "AS IS," WITHOUT A WARRANTY OF 
 * 	ANY KIND. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS 
 * 	AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, 
 * 	FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, 
 * 	ARE HEREBY EXCLUDED. OBIX LABS LIMITED ("Obix Labs") AND ITS 
 * 	LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE 
 * 	AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR 
 * 	ITS DERIVATIVES. IN NO EVENT WILL Obix Labs OR ITS LICENSORS BE 
 * 	LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, 
 * 	INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE 
 * 	DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF 
 * 	LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS 
 * 	SOFTWARE, EVEN IF Obix Labs HAS BEEN ADVISED OF THE POSSIBILITY OF 
 * 	SUCH DAMAGES.
 */
package com.obixlabs.commons.security;

/**
 * <p>
 * An interface which encapsulates a password rule or requirement. When implementing 
 * a custom password rule, you should consider 
 * extending {@link AbstractCharPresencePasswordRequirement}.  
 * </p>
 * 
 * @see PasswordGenerator
 * @see PasswordBuffer
 * @see SimpleAlphaCharsFillPasswordRequirement
 * @see MinNonAlpaNumericCharsPasswordRequirement
 * @see MinNumericCharsPasswordRequirement
 * @see MinLowerCaseCharsPasswordRequirement
 * @see MinUpperCaseCharsPasswordRequirement
 */
public interface PasswordRequirement
{
        /**
         * <p>
         * Attempts to apply this rule to the given {@link PasswordBuffer password buffer}.  
         * This may involve changing the contents of the buffer or simply validating them to
         * ensure that the rule is satisfied. 
         * </p>
         * @param buffer        The {@link PasswordBuffer buffer} to which the rule should be applied. 
         * @return      <code>True</code> if the either the rule is already satisfied by the buffer, or 
         * if the buffer was successfully changed to satisfy the rule. <code>False</code> if the buffer
         * does not satisfy the rule and no further changes could be made to the buffer to meet the rule.
         */
	boolean apply(PasswordBuffer buffer);

	/**
	 * <p>
	 * This should ideally be a human readable description of the rule.
	 * </p>
	 * @return     A description of the rule.
	 */
	String getDescription();
}
